﻿namespace Acoris.ViewModels
{
    using System.ComponentModel;
    using System.Runtime.CompilerServices;

    public class ViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// 为指定对象复制并触发PropertyChanged事件
        /// </summary>
        /// <typeparam name="T">数据类型</typeparam>
        /// <param name="source">数据源</param>
        /// <param name="value">新值</param>
        /// <param name="name">该值有编译器确定</param>
        protected void Set<T>(ref T source, T value, [CallerMemberName]string name = "")
        {
            source = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }
}
